package com.ly.erms.modular.erms.service.impl;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import com.ly.erms.common.persistence.dao.PubliclibraryDatarecordMapper;
import com.ly.erms.common.persistence.model.PubliclibraryDatarecord;
import com.ly.erms.core.shiro.ShiroKit;
import com.ly.erms.modular.erms.service.IDatarecordService;

/**
 * <p>
 * 文件主表 服务实现类
 * </p>
 *
 * @author liuyang
 * @since 2018-01-15
 */
@Service
public class DatarecordServiceImpl implements IDatarecordService {
	
	@Resource
	PubliclibraryDatarecordMapper datarecordMapper;

	@Override
	public Integer AddInDatarecord(MultipartFile file,Integer classificationId,String filePath) {
		PubliclibraryDatarecord datarecord = new PubliclibraryDatarecord();
		datarecord.setCreatetime(new Date());
		datarecord.setFilename(file.getOriginalFilename());
		datarecord.setAuthorid(ShiroKit.getUser().getId());
		datarecord.setAuthor(ShiroKit.getUser().getName());
		datarecord.setDocpath(filePath);
		datarecord.setPid(classificationId);
		Integer insert = datarecordMapper.insert(datarecord);
		return insert;
	}

}
